package com.pug.user.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.pug.user.dto.AccessLog1ReqDTO;
import com.pug.user.mapper.AccessLog1Mapper;
import com.pug.user.po.AccessLog1PO;
import com.pug.user.service.IAccessLog1Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author RenGaoshuai
 * @date 2023/5/9 15:14
 * @description
 */
@Service
@Slf4j
public class AccessLog1ServiceImpl implements IAccessLog1Service {

    @Autowired
    private AccessLog1Mapper AccessLog1Mapper;

    @Override
    public Integer saveLogger(AccessLog1ReqDTO reqDTO) {
        AccessLog1PO po = BeanUtil.copyProperties(reqDTO, AccessLog1PO.class);
        po.setId(IdUtil.getSnowflakeNextId());
        Date date = new Date();
        po.setCreateTime(date);
        po.setUpdateTime(date);
        po.setIsDelete(0);
        log.info("日志入库成功");
        return AccessLog1Mapper.insert(po);

    }
}
